﻿#region Version Info
/* ========================================================================
* 【本类功能概述】
* 
* 作者：李荣楠
* 时间：2013-10-30 13:47:46
* 文件名：Login
* .net版本：4.0 
* ========================================================================
*/
#endregion
using LCL.Common;
using LCL.Home;
namespace LCL.Business
{
    /// <summary>
    /// 用户操作类
    /// </summary>
    public class Users
    {
        //public EnumLoginState CheckUser(int uID, string pwd, int isAdmin)
        //{

        //}
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="username"></param>
        /// <param name="pwd"></param>
        /// <param name="email"></param>
        /// <returns></returns>
        public static bool RegUser(string username,string pwd,string email)
        {
            return DatabaseProvider.GetInstance().RegUser(username, Input.MD5(pwd, false), email);
        }
        /// <summary>
        /// 开始登陆
        /// </summary>
        /// <param name="uname">用户名</param>
        /// <param name="pwd">密码</param>
        /// <param name="isAdmin">是否是管理员</param>
        /// <returns></returns>
        public static bool Login(string uname, string pwd, bool isAdmin)
        {
            string uid = "0";
            string MD5pwd=Input.MD5(pwd,false);
            if (DatabaseProvider.GetInstance().Login(ref uid, uname, MD5pwd, isAdmin))
            {
                //保存cookie
                Input.SetCookie(uid, uname, MD5pwd, false);
                return true;
            }
            return false; ;
        }
    }
}
    